package com.example.xiaodu.yuejian12.Fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.xiaodu.yuejian12.Adapter.ShowAdapter;
import com.example.xiaodu.yuejian12.Bean.ShowBean;
import com.example.xiaodu.yuejian12.Listener.RetrofitListener;
import com.example.xiaodu.yuejian12.Model.UserModel;
import com.example.xiaodu.yuejian12.R;

import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class ShowFragment extends Fragment {


    private RecyclerView recyclerView;
    private UserModel userModel;
    private RetrofitListener<List<ShowBean>> listener;
    private LinearLayoutManager linearLayoutManager;
    private ShowAdapter showAdapter;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view=inflater.inflate(R.layout.fragment_show,container,false);
        showAdapter=new ShowAdapter();
        recyclerView = view.findViewById(R.id.showRecyclerView);
        linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(showAdapter);
        listener=new RetrofitListener<List<ShowBean>>() {
            @Override
            public void onSuccess(List<ShowBean> list) {
                showAdapter.setData(list);
            }

            @Override
            public void onFail(String msg) {

            }
        };
        // Inflate the layout for this fragment
      userModel=new UserModel();
        userModel.getAllShow(listener);
        return view;
    }

}
